#include "handler.h"

handler::handler()
{


}

void handler::handleGetMap(ArNetPacket *packet)
{
     char buffer[10000];
     int x;

     if (packet->getDataReadLength() == packet->getDataLength())
     {
       printf("Empty packet signifying end of map (for central forward)\n");
       return;
     }

     packet->bufToStr(buffer, sizeof(buffer));
     // if we got an end of line char instead of a line it means the map is over
     if (buffer[0] == '\0')
     {
       arMap.parsingComplete();

       //Imprimir mapa here

       std::vector <ArPose> *puntos;
       puntos = arMap.getPoints();

       for(x=0;x<puntos->size();x++){

           ArPose temp;
           temp = puntos->at(x);

           MW->public_draw_Ellipse(temp.getX(),temp.getY(),1,1,Qt::black,Qt::red);
       }

       std::vector <ArLineSegment> *lineas;
       lineas = arMap.getLines();

       for(x=0;x<lineas->size();x++){

           ArLineSegment temp2;
           temp2 = lineas->at(x);

          // MW->public_draw_Line(temp2.getX1(),temp2.getY1(),temp2.getX2(),temp2.getY2(),Qt::black);
       }


     }
     else
     {
       arMap.parseLine(buffer);
     }

}
